import { defHttp } from '/@/utils/http/axios';
import {SysTenant, SysTenantListGetResultModel} from '/@/model/system/sysTenantModel';
import {ErrorMessageMode} from "/#/axios";

enum Api {
  GET_SYS_TENANT_PAGE_LIST = '/upms/sysTenant/page',
  GET_SYS_TENANT_BY_ID = '/upms/sysTenant/',
  SYS_TENANT_UPDATE = '/upms/sysTenant/updateById',
  SYS_TENANT_SAVE = '/upms/sysTenant/save',
  SYS_TENANT_DEL = '/upms/sysTenant/logicalRemoveById/',
}

/**
 * @description: Get sample list value
 */

export const getSysTenantListApi = (params: {}) =>
  defHttp.get<SysTenantListGetResultModel>(
    {url: Api.GET_SYS_TENANT_PAGE_LIST,params },
    { errorMessageMode: 'message' }
  );

export const getSysTenantByIdApi = (id) =>
  defHttp.get<SysTenant>(
    {url: Api.GET_SYS_TENANT_BY_ID+id },
    { errorMessageMode: 'message' }
  );

export function sysTenantUpdateApi(params: SysTenant, mode: ErrorMessageMode = 'modal') {
  return defHttp.put<SysTenant>(
    {
      url: Api.SYS_TENANT_UPDATE,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
export const sysTenantDelByIdApi = (id) =>
  defHttp.delete<SysTenant>(
    {url: Api.SYS_TENANT_DEL+id },
    { errorMessageMode: 'message' }
  );


export function sysTenantSaveApi(params: SysTenant, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<SysTenant>(
    {
      url: Api.SYS_TENANT_SAVE,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
